﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using System.Data.SqlClient;
using DoAnOOP.BussinessLayer;
namespace DoAnOOP
{
    public partial class frmSinhVien : DevComponents.DotNetBar.Office2007Form
    {
        int count_Khoa = 0;
        int count_Gioitinh = 0;
        int count_NgaySinh = 0;
        int count_NgayVaoDoan = 0;
        public frmSinhVien()
        {
            InitializeComponent();
        }
       
        private void textBox3_TextChanged(object sender, EventArgs e)
        {
        }
        private void frmSinhVien_Load(object sender, EventArgs e)
        {
            FillAll();
        }
        public void FillAll()
        {
            clsBusLyLichSV clsMyLyLichSV = new clsBusLyLichSV();
            txt_mssv.Text = clsMyLyLichSV.GetMSSV();
            txt_Ho.Text = clsMyLyLichSV.GetHo();
            txt_Ten.Text = clsMyLyLichSV.GetTen();
            txt_Email.Text = clsMyLyLichSV.GetEmail();
            txt_NoiSinh.Text = clsMyLyLichSV.GetNoiSinh();
            rbn_nam.Checked = clsMyLyLichSV.GetGioiTinh();
            rbn_nu.Checked = !clsMyLyLichSV.GetGioiTinh();
            dateTime_nvdoan.Value = clsMyLyLichSV.GetNgayVaoDoan();
            dateTime_NgaySinh.Value = clsMyLyLichSV.GetNgaySinh();
            List<string> ds_khoa = new List<string>();
            ds_khoa = clsMyLyLichSV.GetDanhSachKhoa();
            for (int i = 0; i < ds_khoa.Count; i++)
            {
                cbx_khoa.Items.Add(ds_khoa[i]);
            }
            cbx_khoa.Text = clsMyLyLichSV.GetMaKhoa();
        }
        private void txt_Email_MyEvent(object sender, MyEventArgs e)
        {
            clsBusLyLichSV clsMyLyLichSV = new clsBusLyLichSV();
            DialogResult kq = MessageBox.Show("Bạn có muốn thay đổi?", "Thông báo", MessageBoxButtons.OKCancel);
            if (kq == System.Windows.Forms.DialogResult.OK)
            {
                clsMyLyLichSV.Update_Email(txt_Email.Text);
                txt_Email.Refresh();
            }
        }
        private void txt_NoiSinh_MyEvent(object sender, MyEventArgs e)
        {
            clsBusLyLichSV clsMyLyLichSV = new clsBusLyLichSV();
            DialogResult kq = MessageBox.Show("Bạn có muốn thay đổi?", "Thông báo", MessageBoxButtons.OKCancel);
            if (kq == System.Windows.Forms.DialogResult.OK)
            {
                clsMyLyLichSV.Update_NoiSinh(txt_NoiSinh.Text);
                txt_NoiSinh.Refresh();
            }
        }
        private void txt_Ho_MyEvent(object sender, MyEventArgs e)
        {
            clsBusLyLichSV clsMyLyLichSV = new clsBusLyLichSV();
            DialogResult kq = MessageBox.Show("Bạn có muốn thay đổi?", "Thông báo", MessageBoxButtons.OKCancel);
            if (kq == System.Windows.Forms.DialogResult.OK)
            {
                clsMyLyLichSV.Update_Ho(txt_Ho.Text);
                txt_Ho.Refresh();
            }
        }
        private void txt_Ten_MyEvent(object sender, MyEventArgs e)
        {
            clsBusLyLichSV clsMyLyLichSV = new clsBusLyLichSV();
            DialogResult kq = MessageBox.Show("Bạn có muốn thay đổi?", "Thông báo", MessageBoxButtons.OKCancel);
            if (kq == System.Windows.Forms.DialogResult.OK)
            {
                clsMyLyLichSV.Update_Ten(txt_Ten.Text);
                txt_Ten.Refresh();
            }
        }
        private void cbx_khoa_SelectedValueChanged(object sender, EventArgs e)
        {
            count_Khoa++;
            if (count_Khoa > 1)
            {
                clsBusLyLichSV clsMyLyLichSV = new clsBusLyLichSV();
                clsMyLyLichSV.Update_MaKhoa(cbx_khoa.Text);
            }
        }

        private void dateTime_NgaySinh_ValueChanged(object sender, EventArgs e)
        {
            count_NgaySinh++;
            if (count_NgaySinh >= 1)
            {
                clsBusLyLichSV clsMyLyLichSV = new clsBusLyLichSV();
                clsMyLyLichSV.Update_NgaySinh(dateTime_NgaySinh.Value.ToString(frmMain.TimeFormat));
            }
        }

        private void dateTime_nvdoan_ValueChanged(object sender, EventArgs e)
        {
            count_NgayVaoDoan++;
            if (count_NgayVaoDoan > 1)
            {
                clsBusLyLichSV clsMyLyLichSV = new clsBusLyLichSV();
                clsMyLyLichSV.Update_NgayVaoDoan(dateTime_nvdoan.Value.ToString(frmMain.TimeFormat));
            }
        }

        private void rbn_nam_CheckedChanged(object sender, EventArgs e)
        {
            count_Gioitinh++;
            if (count_Gioitinh > 1)
            {
                if (rbn_nam.Checked == true)
                {
                    clsBusLyLichSV clsMyLyLichSV = new clsBusLyLichSV();
                    clsMyLyLichSV.Update_GioiTinh("Nam");
                }
            }
        }

        private void rbn_nu_CheckedChanged(object sender, EventArgs e)
        {
            if (rbn_nu.Checked == true)
            {
                clsBusLyLichSV clsMyLyLichSV = new clsBusLyLichSV();
                clsMyLyLichSV.Update_GioiTinh("Nữ");
            }

        }

        private void txt_NoiSinh_Load(object sender, EventArgs e)
        {

        }

        

        

       





    }
}